Present-day application programs almost never interface directly to the hardware of the computer system in which they execute. Instead, application program interfaces (APIs) call code modules which control the hardware, or which call programmed interfaces at yet lower levels. Most API code modules reside in an operating system (OS), although others may exist in a basic input/output system (BIOS), or in other places. Code modules for API functions typically reside in freestanding dynamic link library (DLL) files each containing routines for carrying out dozens or even hundreds of API functions.
Executing an application program written for one computer processor, operating system, or other platform on another platform requires a program, variously known as an emulator, simulator, interpreter, or translator, to convert instructions, data formats, application-program interfaces (APIs), and other characteristics of the application from those of its original platform to those of the native platform in which the emulator runs. Sometimes the original platform has been replaced, but the old application must still be run on the new platform. Sometimes programs are written to an abstract platform, so that the same application can be executed on numerous different platforms merely by writing an emulator for each native platform that is to host the abstract platform.
An emulator subsystem generally has two major components. The emulator itself converts the original processor instructions from the application into instructions or groups of instructions appropriate to the processor of the new platform, and executes them. An API translation layer "thunks" API calls from the original platform being emulated into calls to APIs written for the native platform; that is, it intercepts API calls made by an application written for the emulated platform, converts their arguments from the calling convention of the original platform to that of the native platform, then calls an appropriate native-platform module for executing the API function. A translation module or "API thunk" is a piece of program code in the translation layer which executes between a particular original API and the operating system running on the native platform.
Conventional practice involves hand-writing thunk code for each new and modified API. However, an API set may change daily during the development of an operating system. Also, the number of APIs can be very large. The Microsoft Windows NT operating system, for example, contains more than 3,500 APIs in 42 different DLL modules. Therefore, manual production of individual API translation code becomes increasingly impractical. Increasingly shorter product cycles compounds this problem.
Some interface modules or thunks have been generated from handwritten descriptors for each separate API. However, these must be maintained separately from the APIs themselves, and thus involve costly additional effort. They also suffer from "synchronization" problems: if one or more modules inadvertently escape an update between one development iteration and the next, their down-level code may mistranslate an API, or may crash the system. Such problems can be difficult to find, thus forcing the entire development effort to wait.
Alternatively, a software tool has been employed to create a set of skeleton API thunks as C-language source files which were then hand-modified. This approach is impractical, in that rerunning the tool destroys all the hand edits.